﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace Maticsoft.Web
{
    public partial class UserOrderDetail : PageBaseMember
    {
        int _OrderId;
        protected int _StatusId;
        protected void Page_Load(object sender, EventArgs e)
        {
            Check();

            int.TryParse(Request.QueryString["orderId"], out _OrderId);

            GetOrder();
            BindOitem();
        }

        protected void GetOrder()
        {
            BLL.Orders orderBLL = new BLL.Orders();
            Model.Orders orderModel = orderBLL.GetModel(_OrderId);
            _StatusId = (int)orderModel.Status;
            ltlAddress.Text = orderModel.Address;
            ltlMobile.Text = orderModel.Mobile;
            ltlName.Text = orderModel.Name;
            ltlCreateTime.Text = ((DateTime)orderModel.CreateTime).ToString("yyyy-MM-dd HH:mm:ss");
            ltlOrderNo.Text = orderModel.OrderNo;

            BLL.OrderStatus statBLL = new BLL.OrderStatus();
            Model.OrderStatus statModel = statBLL.GetModel((int)orderModel.Status);
            ltlStatus.Text = statModel.OrderStatusNameCus;

            BLL.LogisticsInfo logiBLL = new BLL.LogisticsInfo();
            DataSet dss = logiBLL.GetList("OrderId=" + orderModel.OrderId + " order by CreateTime");
            Repeater2.DataSource = dss.Tables[0].DefaultView;
            Repeater2.DataBind();
        }

        protected void BindOitem()
        {
            BLL.Oitems oitemBLL = new BLL.Oitems();
            DataSet ds = oitemBLL.GetList("OrderId=" + _OrderId);
            Repeater1.DataSource = ds.Tables[0].DefaultView;
            Repeater1.DataBind();
        }
    }
}